using System.Collections.Generic;

namespace PropertyExpression.Common
{
    public static class DictionaryExtensions
    {
        public static IOption<TValue> GetOptionalValue<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key)
        {
            TValue value;
            return dictionary.TryGetValue(key, out value) ? value.AsOption() : Option.Nothing<TValue>();
        }
    }
}